﻿<#include "include/_meta.html">
<title>黑名单列表</title>

<script type="text/javascript" src="/lib/jquery/1.9.1/jquery.min.js"></script>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 管理员管理 <span
            class="c-gray en">&gt;</span> 黑名单列表 <a class="btn btn-success radius r"
                                                   style="line-height:1.6em;margin-top:3px"
                                                   href="javascript:location.replace(location.href);" title="刷新"><i
                class="Hui-iconfont">&#xe68f;</i>
    </a>
</nav>

<div class="page-container">
    <div class="text-c">

        客户名称:
        <input type="text" class="input-text" style="width:250px" placeholder="输入客户姓名" id="custormerName" name="">
        手机号:
        <input type="text" class="input-text" style="width:250px" placeholder="输入客户手机号" id="custormerPhone" name="">

        <button class="btn btn-success" id="chaXunBalckList"><i class="Hui-iconfont">&#xe665;</i>
            查询黑名单人员
        </button>

    </div>

    <div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l">
	 <a href="javascript:;" id="addBlackList" class="btn btn-primary radius"><i
                 class="Hui-iconfont">&#xe600;</i>新增黑名单</a></span>
       </div>


    <table class="table table-border table-bordered table-bg table-hover" id="ListTable">
        <thead>
        <tr>
            <th scope="col" colspan="9">黑名单列表</th>
        </tr>
        <tr class="text-c">
            <th width="40"><input type="checkbox" name="useritem" value=""></th>

            <th hidden="hidden" width="150">客户ID</th>
            <th width="150">客户姓名</th>
            <th width="90">手机号</th>
            <th width="150">身份证号</th>
            <th width="70">原因类型</th>
            <th width="70">操作</th>
        </tr>
        </thead>

        <tbody>
        <tr class="text-c" v-for="(it,index) in result">
            <th width="40"><input type="checkbox" name="useritem" value="" id="check"></th>

            <th hidden="hidden">{{it.custormerId}}</th>
            <td>{{it.custormerName}}</td>
            <td>{{it.custormerPhone}}</td>
            <td>{{it.custormerIdCard}}</td>
            <td>{{it.custormerStateRemark}}</td>
            <td>
                <a href="#" @click="editEvent(it.custormerId)">编辑</a>
                <a href="#" @click="delEvent(it.custormerId)">删除</a>
            </td>
        </tr>
        </tbody>
        <tr>
            <td colspan="9">
                <div id="pagenav"></div>
            </td>
        </tr>
    </table>
</div>

<script>

    var app = new Vue({
        el: '#ListTable',
        data: {
            result: []
        }
    });

    var getBackList = function (curr) {
        $.ajax({
            type: 'post',
            datatype: 'json',
            url: '/getAllBlackList',
            data: {
                pageNum: curr || 1,
                pageSize: 4,
                custormerName: $("#custormerName").val(),
                custormerPhone: $("#custormerPhone").val(),
            },
            success: function (msg) {
                app.result = msg.list;

                laypage({
                    cont: "pagenav",
                    pages: msg.total,
                    skin: "#DB7099",
                    first: "第一页",
                    last: "最后一页",
                    curr: curr || 1,
                    jump: function (obj, first) {
                        if (!first) {
                            getBackList(obj.curr);
                        }
                    }
                });
            }
        });
    };

    getBackList();

    $("#chaXunBalckList").click(function () {
        getBackList();
    });

    //新增黑名单
    $("#addBlackList").on("click", function () {
        layer.open({
            type: 2,
            title: '新增黑名单',
            fix: false,
            maxmin: true,
            shadeClose: true,
            area: ['800px', '550px'],
            content: '/add',
            end: function () {
                getBackList();
            }
        });
    });

    //黑名单编辑
    var editEvent = function (custormerId) {
        layer.open({
            type: 2,
            title: '编辑黑名单',
            fix: false,
            maxmin: true,
            shadeClose: true,
            area: ['800px', '550px'],
            content: '/toupdate?custormerId=' + custormerId,
            end: function () {
                getBackList();
            }
        });
    };

    //删除用户
    var delEvent = function (id) {
        //询问框
        layer.confirm("确认删除吗？",
            {btn: ['是', '否']},
            //是
            function () {
                $.ajax({
                    type: 'post',
                    dataType: 'json',
                    url: '/delBlackList',
                    data: {
                        custormerId: id
                    },
                    success: function (result) {
                        if (result == '1')
                            layer.msg("已经成功删除记录" + id, {icon: 5});
                        getBackList();
                    }
                })
            },
            //否
            function () {
            }
        );
    }
</script>

<#include "include/_footer.html">

</body>
</html>